{{ $books := slice}}

{{ range where .Site.Pages "Section" "books" }}
  {{ with .File }}
    {{ $subDirsNumer := .File.Path | strings.Count "/" }}
    {{ if eq $subDirsNumer 2 }}
      {{ $books  = $books  | append (dict "page" . "path" .File.Path) }}
    {{ end }}
  {{ end }}
{{ end }}

{{ partial "global-search.html" . }}

<h1>{{ i18n "books" }}</h1>

<p>{{ i18n "list-desc-books" }}</p>

<hr class="line"/>

{{ $books := slice}}

{{ range where .Site.Pages "Section" "books" }}
  {{ $subDirsNumer := .File.Path | strings.Count "/" }}
  {{ if eq $subDirsNumer 2 }}
    {{ $books  = $books  | append (dict "page" . "path" .File.Path) }}
  {{ end }}
{{ end }}

<ul class="documents-list">
{{ range sort $books "bookOrder" "path" }}
  {{ if in .path "_index.adoc" }}
    {{ $bookPath := replaceRE "/_index.adoc" "" .path }}
    {{ $bookPath = replaceRE "books/" "" $bookPath }}
    {{ $articleName := replaceRE "books/" "" $bookPath }}
    <li>
      <a href="{{ $bookPath }}"><strong>{{ .page.Title }}</strong></a>
      <p>{{ .page.Params.description }}</p>
    </li>
  {{ end }}
{{ end }}
</ul>
